/**
 * ES6 类继承
 */
class People {
  constructor(name, age){
    // 实例属性
    this.name = name
    this.age = age
    // 引入属性 防止sex 设置值死循环
    this._sex = -1
  }
  // 类顶层定义类实例属性 只读
  get sex(){
    if(this._sex === 1){
      return 'male'
    } else if(this._sex === 0){
      return 'famale'
    } else{
      return 'unknow'
    }
  }

  set sex(val){
    if(val === 0 || val === 1){
      this._sex = val
    }
  }

  getName(){
    console.log(this.name)
  }

  // 定义静态方法
  static getCount(){
    return 3
  }

  // 没有静态属性
}

// 类似 es5 定义静态方法
People.count = 5


let p = new People('aqie', 18)
console.log(p, People.getCount())


class Coder extends People{
  constructor(name, age, company){
    super(name,age)
    this.company = company
  }
}

let c = new Coder('bqie', 19,'baidu')
c.sex = 0
console.log(c, c.sex, Coder.getCount(), typeof(Coder))
